package com.unswift.window.extend;

import java.util.HashMap;
import java.util.Map;

public class Attribute {
	
	//label
	public static final String ATTRIBUTE_LABEL_TEXT="text";//值
	public static final String ATTRIBUTE_LABEL_ALIGN="align";//水平居中方式
	public static final String ATTRIBUTE_LABEL_TIPS="tips";//垂直居中方式
	public static final String ATTRIBUTE_LABEL_ICON="icon";//图标
	
	//表单相关属性
	public static final String ATTRIBUTE_FORM_VALUE="value";//值
	public static final String ATTRIBUTE_FORM_ALIGN="align";//水平居中方式
	public static final String ATTRIBUTE_FORM_VALIGN="valign";//垂直居中方式
	public static final String ATTRIBUTE_FORM_EDITABLE="editable";//是否可编辑
	public static final String ATTRIBUTE_FORM_ENABLED="enabled";//是否禁用
	public static final String ATTRIBUTE_FORM_MARGIN="margin";//字体离边框距离
	public static final String ATTRIBUTE_FORM_COLOR="color";//字体颜色
	public static final String ATTRIBUTE_FORM_BGCOLOR="bgcolor";//背景颜色
	public static final String ATTRIBUTE_FORM_FOCUS="focus";//是否获取焦点
	public static final String ATTRIBUTE_FORM_SELECT_OPTIONS="selectOptions";//下拉框选项
	public static final String ATTRIBUTE_FORM_ICON="icon";//图标；复选框、单选框
	public static final String ATTRIBUTE_FORM_ACTION="action";//图标；复选框、单选框、Editor
	public static final String ATTRIBUTE_FORM_SELECT="select";//是否选中；复选框、单选框
	public static final String ATTRIBUTE_FORM_HEIGHT="height";//组件高度,textarea为行的数量
	public static final String ATTRIBUTE_FORM_HEIGHT_AUTO="heightAuto";//组件高度自动
	public static final String ATTRIBUTE_FORM_BORDER="border";//边框
	public static final String ATTRIBUTE_FORM_PLACEHOLDER="placeholder";//边框
	public static final String ATTRIBUTE_FORM_KEY_LISTENER="keyListener";//键盘监听
	public static final String ATTRIBUTE_FORM_INPUT_DOCUMENT="inputDocument";//输入框document
	public static final String ATTRIBUTE_FORM_SELECT_LISTENER="selectListener";//下拉框事件
	public static final String ATTRIBUTE_FORM_EDITOR_LINES="editorLines";//下拉框事件
	public static final String ATTRIBUTE_FORM_COLUMNS="columns";//输入框的长度
	//按钮
	public static final String ATTRIBUTE_BUTTON_ORIGINAL="original";//原始按钮，默认不是原始
	public static final String ATTRIBUTE_BUTTON_NAME="name";//按钮名称
	public static final String ATTRIBUTE_BUTTON_ICON="icon";//按钮名称
	public static final String ATTRIBUTE_BUTTON_TIPS="tips";//按钮tips
	public static final String ATTRIBUTE_BUTTON_ACTION="action";//按钮action
	public static final String ATTRIBUTE_BUTTON_OPAQUE="opaque";//透明
	public static final String ATTRIBUTE_BUTTON_ENABLED="enabled";//是否可见
	public static final String ATTRIBUTE_BUTTON_MARGIN="margin";//外边距
	public static final String ATTRIBUTE_BUTTON_PADDING="padding";//内边距
	public static final String ATTRIBUTE_BUTTON_BGCOLOR="bgcolor";//内边距
	public static final String ATTRIBUTE_BUTTON_SIZE="size";//内边距
	public static final String ATTRIBUTE_BUTTON_FOCUS="focus";//
	public static final String ATTRIBUTE_BUTTON_DEPEND="depend";//依赖
	//文件选择器相关属性
	public static final String ATTRIBUTE_FILECHOOSE_DEFAULT_FILEPATH="defaultPath";//默认路径
	public static final String ATTRIBUTE_FILECHOOSE_DEFAULT_FILENAME="defaultFileName";//默认文件
	public static final String ATTRIBUTE_FILECHOOSE_ENABLED="enabled";//是否禁用
	public static final String ATTRIBUTE_FILECHOOSE_MULTISELECTION_ENABLED="enabled";//是否多选
	public static final String ATTRIBUTE_FILECHOOSE_FILTER="filter";//文件过滤器
	public static final String ATTRIBUTE_FILECHOOSE_DEPEND="depend";//依赖frame
	public static final String ATTRIBUTE_FILECHOOSE_TYPE="chooseType";//文件选择器选择类型
	//表格
	public static final String ATTRIBUTE_TABLE="table";//table对象
	public static final String ATTRIBUTE_TABLE_COLUMN_INDEX="columnIndex";//列下标
	public static final String ATTRIBUTE_TABLE_COLUMN_MIN_WIDTH="minWidth";//列最小宽度
	public static final String ATTRIBUTE_TABLE_COLUMN_MAX_WIDTH="maxWidth";//列最大宽度
	public static final String ATTRIBUTE_TABLE_COLUMN_EDITOR="editor";//编辑单元格对象（JTextField等）
	public static final String ATTRIBUTE_TABLE_COLUMN_EDITOR_TEXT="text";//编辑单元格对象-文本
	public static final String ATTRIBUTE_TABLE_COLUMN_EDITOR_SELECT="select";//编辑单元格对象-下拉
	public static final String ATTRIBUTE_TABLE_COLUMN_EDITOR_CHECKBOX="checkbox";//编辑单元格对象-复选
	public static final String ATTRIBUTE_TABLE_COLUMN_EDITOR_OPTIONS="options";//编辑单元格对象-选项,复选框时是字符串，下拉、单选、复选时才有效
	public static final String ATTRIBUTE_TABLE_COLUMN_EDITOR_AUTO="auto";//编辑单元格对象-下拉
	public static final String ATTRIBUTE_TABLE_COLUMN_EDITOR_DEFAULT="default";//编辑单元格对象-下拉
	public static final String ATTRIBUTE_TABLE_COLUMN_FORMAT="columnFormat";//自定义格式对象，一般，第一列传图标，后续列可传入对象声明居中方式
	//编辑器
	public static final String ATTRIBUTE_SQL_EDITOR_TAB_INDEX="tabIndex";
	public static final String ATTRIBUTE_SQL_EDITOR_SELECTION_START="start";
	public static final String ATTRIBUTE_SQL_EDITOR_SEARCH_INDEX="searchIndex";
	public static final String ATTRIBUTE_SQL_EDITOR_CONN="conn";
	public static final String ATTRIBUTE_SQL_EDITOR_DATABASE="database";
	public static final String ATTRIBUTE_SQL_EDITOR_SQL="sql";
	public static Attribute create(){
		return new Attribute();
	}
	
	private Map<String, Object> attribute;
	public Attribute() {
		attribute=new HashMap<String, Object>();
	}
	
	public Attribute put(String key, Object value){
		attribute.put(key, value);
		return this;
	}
	
	public boolean exists(String key){
		return attribute.containsKey(key);
	}
	
	public Map<String, Object> get() {
		return attribute;
	}
	
	@SuppressWarnings("unchecked")
	public <T> T get(String key){
		return (T)attribute.get(key);
	}
}
